/***********************************************************************
 * Module:  ControlTaskToVehicleService.java
 * Author:  Administrator
 * Purpose: Defines the Class ControlTaskToVehicleService
 ***********************************************************************/

package ishitong.rvims.control.service;

import ishitong.rvims.control.persistence.ControlTaskToVehicleMapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ishitong.rvims.domain.control.ControlTask;
import ishitong.rvims.domain.control.ControlVehicle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/** @pdOid 8adad1ba-f9b2-476a-b0ae-61f9883545aa */
@Service
public class ControlTaskToVehicleService {
   /** @pdOid a44e9d42-7f95-4791-a821-0c1ba967076d
       @pdRoleInfo migr=yes name=ControlTaskToVehicleMapper assc=association6 */
   @Autowired
   private ControlTaskToVehicleMapper controlTaskToVehicleMapper;
   
   /** @param controlVehicleId
    * @pdOid 0dd68199-0f3c-4bc7-b739-41caf6d1cc6b */
   public void deleteByControlVehicleId(String controlVehicleId) {
      controlTaskToVehicleMapper.deleteByControlVehicleId(controlVehicleId);
   }
   
   /** @param controlVehicleIds 
    * @param controlTaskIds
    * @pdOid 7f7f07e6-5a0e-43f0-a31f-39fe22358f45 */
   public void updateControlTaskToVehicle(String[] controlVehicleIds, String[] controlTaskIds) {
      // TODO: implement
    HashMap<String,Integer> cphm = new HashMap<String,Integer>();
    for(int i = 0 ; i < controlTaskIds.length ; i ++)
    {
     for (int j = 0 ; j < controlVehicleIds.length ; j ++)
     {
   	  cphm.put("ID", Integer.parseInt(controlVehicleIds[j]));
   	  cphm.put("T_C_ID", Integer.parseInt(controlTaskIds[i]));
   	  controlTaskToVehicleMapper.insertControlTaskToVehicle(cphm);
     }
    }
   }
   
   /** @param controlTaskId
    * @pdOid 3e24ae60-cafc-4c05-861f-3501645ce644 */
   public void deleteControlVehicleByControlTaskId(String controlTaskId) {
      // TODO: implement
    controlTaskToVehicleMapper.deleteControlVehicleByControlTaskId(controlTaskId);
   }
   
   /** @param controlTaskId
    * @pdOid 0cd43902-0390-4aaa-aeb6-5d973e83e198 */
   public List<ControlVehicle> findControlVehicleByControlTaskId(String controlTaskId) {
      // TODO: implement
      return controlTaskToVehicleMapper.selectControlVehicleByControlTaskId(controlTaskId);
   }
   
   /** @param controlVehicleId
    * @pdOid c0deae07-5af6-4dd5-8bc4-a8e49a5324d8 */
   public List<ControlTask> findControlTaskByControlVehicleId(String controlVehicleId) {
      // TODO: implement
      return controlTaskToVehicleMapper.selectControlTaskByControlVehicleId(controlVehicleId);
   }

}